﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Web.DynamicData;
using System.ComponentModel;

namespace Fatec.ControleEstoque.Interface
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Collections.IList visibleTables = MetaModel.Default.VisibleTables;
            if (visibleTables.Count == 0)
            {
                throw new InvalidOperationException("There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages.");
            }
            menu.DataSource = visibleTables;
            menu.DataBind();
        }

        public String GetDescription(Object dataItem)
        {
            String d = ((DescriptionAttribute)((MetaTable)(dataItem)).Attributes[typeof(DescriptionAttribute)]).Description;
            if (!String.IsNullOrEmpty(d))
            {
                return d;
            }
            else
            {
                return "Relação de registros da tabela " + ((MetaTable)(dataItem)).DisplayName;
            }
        }
    }
}
